package ${package.Manager};

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.pine.manager.core.BaseManager;
import ${package.Convertor}.${ConvertorName};
import ${package.Bo}.${BoName};
import ${package.Entity}.${EntityName};
import ${package.Query}.${QueryName};
import ${package.Mapper}.${EntityName}Mapper;
import org.springframework.stereotype.Component;

/**
 * <p>
 * ${table.comment!} 管理类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Component
public class ${EntityName}Manager extends BaseManager<${EntityName}Mapper, ${EntityName}, ${primaryKeyType}, ${BoName}, ${QueryName}, ${ConvertorName}> {

    @Override
    public LambdaQueryWrapper<${EntityName}> encapsulateQueryWrapper(${QueryName} query) {
        LambdaQueryWrapper<${EntityName}> queryWrapper = super.encapsulateQueryWrapper(query);
        if (query == null) {
            return queryWrapper;
        }

// 组装查询条件
<#list QueryFields as field>
    <#if field.date>
        queryWrapper.ge(ObjectUtils.isNotEmpty(query.get${field.capitalName}Start()), ${entity}::get${field.capitalName}, query.get${field.capitalName}Start());
        queryWrapper.le(ObjectUtils.isNotEmpty(query.get${field.capitalName}End()), ${entity}::get${field.capitalName}, query.get${field.capitalName}End());
    <#else>
        queryWrapper.eq(ObjectUtils.isNotEmpty(query.get${field.capitalName}()), ${entity}::get${field.capitalName}, query.get${field.capitalName}());
    </#if>
</#list>

        return queryWrapper;
    }
}
